#include <string>
#include <vector>
#include "Kmeans.h"

using namespace std;

int main (int argc, char const* argv[])
{
	Index index("index/test");
	index.load();
	
	if (argc > 1)
	{
		cout << "Adding document: " << argv[1] << endl;
		string filename (argv[1]);
		HTMLDocument html(filename);
		index.add_document(html);
		index.dump();
	}
	
	std::vector<DocumentVector> docs;
	docs = index.get_documents();
	
	cout << "Unique words: " << index.get_dictionary().size() << endl;
	cout << "Documents: " << docs.size() << endl;
	
	// for (unsigned int i = 0; i < index.get_documents().size(); i++)
	// {
	// 	cout << "doc" << i + 1 << " "<< docs[i] << endl;
	// }
	
	vector<Cluster> clusters;
	
	Kmeans km(index, index.get_documents(), 2);
 	clusters = km.run();
	
	vector<DocumentVector> tmp;
	
	for(unsigned int i = 0; i < clusters.size(); i++)
	{
		cout << "Cluster " << i + 1 << ": " << clusters[i].get_documents().size() << " documents" << endl;
		
		tmp = clusters[i].get_documents();	
		for (unsigned int j = 0; j < tmp.size(); j++)
		{
			cout << j + 1 << ": " << tmp[j].get_identifier() << endl;
		}
	}
	
	return 0;
}